package cloud.seckill.ribbonserver.controller;

import cloud.seckill.ribbonserver.config.loadbalancer.LoadBalancer;
import cloud.seckill.ribbonserver.result.Result;
import cloud.seckill.ribbonserver.service.RedisService;
import cloud.seckill.ribbonserver.service.RibbonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @title: TestController
 * @Author Wangsj
 * @Date: 2021/5/24
 */

@Api(tags = "后门接口")
@RestController
@RequestMapping("/backdoor")
public class TestController {
    @Autowired
    RibbonService ribbonService;
    @Autowired
    RedisService redisService;

    @Resource
    private LoadBalancer loadBalancer;

    @ApiOperation(value = "负载均衡测试接口",notes = "轮询")
    @GetMapping("/test/show")
    public Result showInfol(){
        return Result.ok(ribbonService.show());

    }
    @ApiOperation(value = "初始化商品数量")
    @GetMapping("/init")
    public Result initGoogsNum(){
        redisService.InitSeckill();
        loadBalancer.initAtomic();
        return Result.ok();

    }

}
